﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace FakeSMTP
{
    public static class StreamHelper
    {
        public static void Write(this Stream stream, string text)
        {
            var bytes = ASCIIEncoding.ASCII.GetBytes(text);

            stream.Write(bytes, 0, bytes.Length);

        }

        public static string Read(this Stream stream)
        {
            var buffer = new byte[1];
            var text = string.Empty;

            while (stream.Read(buffer, 0, 1) > 0)
            {
                text += ASCIIEncoding.ASCII.GetString(buffer);
            }

            return text;
        }
    }
}
